package com.beiding.fastmock.fram;

import com.beiding.dbrequest.common.SecondWorker;
import com.beiding.fastmock.fram.common.Requester;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/**
 * @author 丁常磊
 * @date 2021/8/2 10:54
 */

@Slf4j
public class Lang {

    public static void load(Map<String, Object> all) {
        all.put("requester", new Requester());
        all.put("log", log);
        all.put("timer", new MyTimer());
    }

    public static class MyTimer {
        public ScheduledFuture timeout(Runnable runnable, long t) {
            return SecondWorker.worker.schedule(runnable, t, TimeUnit.MILLISECONDS);
        }

        public ScheduledFuture interval(Runnable runnable, long t) {
            return SecondWorker.worker.scheduleAtFixedRate(runnable, t, t, TimeUnit.MILLISECONDS);
        }

    }

}
